import React, { useState, useEffect } from 'react'
import { View, Image, Text } from '@tarojs/components'
import {network} from '@/utils/network'
import Taro,{useDidShow} from '@tarojs/taro'
import { ButtonEle } from '@/components/Buttton'
import { Empty } from '@/components/Empty'
import Address from './components/Address'
import './index.scss'

export default () => {
  const [addressList,setAddressList]=useState([])
  const [empty,setEmpty]=useState(false)
  const getData=()=>{
    network.get('/xxm/activity/apply/my').then((res)=>{
      setAddressList(res.data.applyList)
      if(res.data.applyList.length===0){
        setEmpty(true)
      }else{
        setEmpty(false)
      }
    })
  }
  useDidShow(()=>{
    getData()
  })

  return (
    <View className='xxm-address'>
      {addressList.map((item:any)=>(
            <View key={item.id} className='address-container'>
            <Address address={item}></Address>
          </View>
      ))}
      {
         empty&& <Empty img="http://xmmi.oss-cn-beijing.aliyuncs.com/icon/no-data.png"
          desc="暂无报名信息" />
      }
    </View>
  )
}
